package com.example.myapplication.HomeAdapter;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.myapplication.HomeBean.HomeGvShopBean;
import com.example.myapplication.R;

import java.util.ArrayList;
import java.util.List;

public class HomeGvShopAdapter extends BaseAdapter {
    List<HomeGvShopBean>list=new ArrayList<>();
    Activity activity;

    public HomeGvShopAdapter(List<HomeGvShopBean> list, Activity activity) {
        this.list = list;
        this.activity = activity;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        view= LayoutInflater.from(activity).inflate(R.layout.homegv_shop_mokuai,null);
        ImageView img=view.findViewById(R.id.HomeGV_Shop_MoKuai_img);
        TextView name=view.findViewById(R.id.HomeGV_Shop_MoKuai_name);
        TextView guojia=view.findViewById(R.id.HomeGV_Shop_MoKuai_guojia);
        img.setImageResource(list.get(i).getImg());
        name.setText(list.get(i).getName());
        guojia.setText(list.get(i).getGuojia());
        return view;
    }
}
